﻿/*-----------------------------------------------
// File: LinerProjectile.cs
// Description: 线性抛射物
// Author: Shaobing	492057342@qq.com
-----------------------------------------------*/
using UnityEngine;
using System.Collections;

namespace Battle.View
{
    //public class LinerProjectile : BattleProjectile
    //{
    //    public float flySpeed;
    //    public Vector3 flyDir;
    //    public bool isFlying = false;

    //    public Vector3 initPosition;
    //    public Vector3 targetPosition;
    //    protected override void Shoot0()
    //    {
    //        var targetBC = BattleViewCtrl.GetInstance().GetBattleCharacter(targetCamp, targetFPId);
    //        if (targetBC != null)
    //        {
    //            if (!string.IsNullOrEmpty(projResData.targetBindBone))
    //            {
    //                targetPosition = targetBC.GetBonePosition(projResData.targetBindBone);
    //            }
    //            else {
    //                targetPosition = targetBC.GetBeFoundBonePosition();
    //            }
    //        }
    //        else {
    //            targetPosition = BattleViewCtrl.GetInstance().GetPosition(targetFPId, targetCamp);
    //        }
    //        transform.SetParent(creator.transform);
    //        transform.localPosition = Vector3.zero + initOffset;
    //        transform.SetParent(BattleViewCtrl.GetInstance().transform);
    //        initPosition = transform.localPosition;

    //        flySpeed = Vector3.Distance(initPosition, targetPosition) / flyTime;
    //        flyDir = (targetPosition - initPosition).normalized;
    //        isFlying = true;

    //        transform.localScale = Vector3.one;
    //        transform.localEulerAngles = Vector3.zero;
    //    }

    //    public override void Tick()
    //    {
    //        if (isFlying) {
    //            var dis = Vector3.Distance(transform.localPosition, targetPosition);
    //            if (dis <= Time.deltaTime * flySpeed)
    //            {
    //                transform.localPosition = targetPosition;
    //                isFlying = false;
    //            }
    //            else {
    //                var newPos = transform.localPosition + flyDir * flySpeed * Time.deltaTime;
    //                transform.LookAt(newPos);
    //                transform.localPosition = newPos;
    //            }
    //        }
    //    }
    //}
}